package example1;
import java.util.Scanner;

public class WhileSample {

	public static void main(String[] args) {
		System.out.println("使用while循环来接收多个整数的输入，并输出这些整数的平均值。当输入为 0 时，结束输入。");
		Scanner input = new Scanner(System.in);
		int inputValue = 0;
		double sum = 0;
		int account = 0;
		
		System.out.print("请输入整数（输入0结束输入）:");
		while((inputValue = input.nextInt()) != 0) {
			sum += inputValue;
			account++;
		}
		System.out.println("输入数的平均值为" + sum / account);
		
		input.close();
	}

}
